package org.darkforest.common.services.impl;

import org.darkforest.common.services.BrandService;
import org.darkforest.dao.mapper.BrandMapper;
import org.darkforest.model.Brand;
import org.darkforest.model.BrandBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Libing on 2015/6/30.
 */
@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private BrandMapper brandMapper;

    


    /**
     * 品牌集合
     *
     * @return
     */
    @Override
    public List<Brand> selectAllBrand() {
        Brand brand = new Brand();
        brand.setPageSwitch(false);
        List<Brand> brandList = brandMapper.findBrandByCondition(brand);
        return brandList;
    }

    /**
     * 品牌分页列表
     *
     * @param brandBean
     * @return
     */
    @Override
    public BrandBean selectBrandByPage(BrandBean brandBean) {
        List<Brand> brandList = brandMapper.findBrandByPage(brandBean);

        brandBean.setResultList(brandList);
        return brandBean;
    }

    @Override
    public void delBrand(Brand brand) {
        brandMapper.deleteBrandByCondition(brand);
    }

    @Override
    public int addBrand(Brand brand) {
        return brandMapper.insertSelective(brand);
    }

    @Override
    public Brand getBrandInfo(Integer id) {
        return brandMapper.selectByPrimaryKey(id);
    }

    @Override
    public int editBrand(Brand brand) {
        return brandMapper.updateByPrimaryKeySelective(brand);
    }

    /**
     * 根据条件查询品牌信息
     *
     * @param brand
     * @return
     */
    @Override
    public List<Brand> findBrandByCondition(Brand brand) {
        return brandMapper.findBrandByCondition(brand);
    }
}
